package com.cneiu.ppms.web.action;

import com.cneiu.ppms.web.base.BaseController;
import com.cneiu.ppms.web.model.MenuModel;
import com.cneiu.ppms.web.service.MenuService;

/**
 * 菜单控制器
 * @author zhaokf
 * @date 2013-04-23
 */
public class MenuController extends BaseController{
	
	
	
	/**
	 * 菜单添加
	 */
	public void add(){
		try{
			if(!MenuService.isAdd(this.getParams())){
				renderAjax(false, MenuService.getError());
			}else{
				renderAjax(true, "添加菜单信息成功");
			}
		}catch (Exception e){
			e.printStackTrace();
		}

	}

	/**
	 * 菜单编辑
	 */
	public void edit(){
		try{
			if(!MenuService.isUpdate(this.getParams())){
				renderAjax(false, MenuService.getError());
			}else{
				renderAjax(true, "修改菜单信息成功");
			}
		}catch (Exception e){
			e.printStackTrace();
		}
	}
	

	/**
	 * 根据ID查询菜单
	 */
	public void get(){
		try{
			MenuModel model = MenuService.get(this.getParams());
			renderGrid(model);
		}catch (Exception e){
			e.printStackTrace();
		}
	}

	/**
	 * 菜单删除
	 */
	public void delete(){
		try{
			if (!MenuService.isDelete(this.getParams())){
				renderAjax(false, MenuService.getError());
			}else{
				renderAjax(true, "删除菜单信息成功");
			}
		}
		catch (Exception e){
			e.printStackTrace();
		}
	}
}

